<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="####Dagger2项目主页使用依赖123annotationProcessor &amp;apos;com.google.dagger:dagger-compiler:2.2&amp;apos;compile &amp;apos;com.google.dagger:dagger:2.2&amp;apos;provided &amp;apos;javax.annotation:jsr250-api:1.0&amp;apos;">
<meta name="keywords" content="Android、iOS、Web、React Native">
<meta property="og:type" content="article">
<meta property="og:title" content="Android-Dagger2依赖注入">
<meta property="og:url" content="http://yoursite.com/blog/2018/08/06/Android-Framework/Android-Dagger2依赖注入/index.html">
<meta property="og:site_name" content="凌浩雨_博客">
<meta property="og:description" content="####Dagger2项目主页使用依赖123annotationProcessor &amp;apos;com.google.dagger:dagger-compiler:2.2&amp;apos;compile &amp;apos;com.google.dagger:dagger:2.2&amp;apos;provided &amp;apos;javax.annotation:jsr250-api:1.0&amp;apos;">
<meta property="og:locale" content="default">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-20363d0c66b092e6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-4f3946ae7a377334.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-f0c32543ab2645f4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-1c1b1e1c1bf426ae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-f40865ff906700db.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-46f105b5e0abc095.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/3110861-915bd7624ec09cd0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2018-08-06T11:13:10.999Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android-Dagger2依赖注入">
<meta name="twitter:description" content="####Dagger2项目主页使用依赖123annotationProcessor &amp;apos;com.google.dagger:dagger-compiler:2.2&amp;apos;compile &amp;apos;com.google.dagger:dagger:2.2&amp;apos;provided &amp;apos;javax.annotation:jsr250-api:1.0&amp;apos;">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/3110861-20363d0c66b092e6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/blog/2018/08/06/Android-Framework/Android-Dagger2依赖注入/"/>





  <title>Android-Dagger2依赖注入 | 凌浩雨_博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">凌浩雨_博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/blog/blog/2018/08/06/Android-Framework/Android-Dagger2依赖注入/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="凌浩雨">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="凌浩雨_博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Android-Dagger2依赖注入</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-08-06T18:01:38+08:00">
                2018-08-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>####<a href="https://google.github.io/dagger/" target="_blank" rel="noopener">Dagger2项目主页</a><br>使用依赖<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">annotationProcessor &apos;com.google.dagger:dagger-compiler:2.2&apos;</span><br><span class="line">compile &apos;com.google.dagger:dagger:2.2&apos;</span><br><span class="line">provided &apos;javax.annotation:jsr250-api:1.0&apos;</span><br></pre></td></tr></table></figure></p>
<a id="more"></a>
<p>####1. 先创建最基本的四个类<br><img src="http://upload-images.jianshu.io/upload_images/3110861-20363d0c66b092e6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图1.png"><br>代码：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Config &#123;</span><br><span class="line">    public static final String TAG = &quot;Config&quot;;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 引擎</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Engine &#123;</span><br><span class="line">    public Engine()&#123;</span><br><span class="line">        Log.e(Config.TAG, &quot;Engine: new Engine()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 轮子</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Wheel &#123;</span><br><span class="line">    public Wheel()&#123;</span><br><span class="line">        Log.e(Config.TAG, &quot;Wheel: new Wheel()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 车座</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Seat &#123;</span><br><span class="line"></span><br><span class="line">    public Seat()&#123;</span><br><span class="line">        Log.e(Config.TAG, &quot;Seat: new Seat()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>####2. Dagger2是一个依赖注入的框架。</p>
<ul>
<li>之前我们写代码如下， Car类依赖于其他三个类，并且在构造方法中创建其他三个类的对象，这样，Car类在构造方法中对其他三个类的耦合度较高<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 车</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Car &#123;</span><br><span class="line">    private Engine mEngine;</span><br><span class="line">    private Seat mSeat;</span><br><span class="line">    private Wheel mWheel;</span><br><span class="line"></span><br><span class="line">    public Car() &#123;</span><br><span class="line">        mEngine = new Engine();</span><br><span class="line">        mSeat = new Seat();</span><br><span class="line">        mWheel = new Wheel();</span><br><span class="line">        Log.e(Config.TAG, &quot;Car: new Car()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>执行Android单元测试:<br>  <img src="http://upload-images.jianshu.io/upload_images/3110861-4f3946ae7a377334.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图2.png"><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/9</span><br><span class="line"> */</span><br><span class="line">public class CarTest &#123;</span><br><span class="line"></span><br><span class="line">    @Test</span><br><span class="line">    public void testCar()&#123;</span><br><span class="line">        new Car();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<ul>
<li>使用Dagger2之后，先要创建一个CarModule类，再创建一个CarComponent接口或者抽象类，接下来Ctrl+F9进行编译，如果编译成功，则会生成DaggerCarComponent类(生成的Dagger开头，并且后面为Component组件的接口名/抽象类名)，这个类提供注册Module类和注入当前类。<br><img src="http://upload-images.jianshu.io/upload_images/3110861-f0c32543ab2645f4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图3.png"></li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * @Module用来管理并提供依赖</span><br><span class="line"> * @Provides用来提供依赖</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line">@Module</span><br><span class="line">public class CarModule &#123;</span><br><span class="line">    @Provides</span><br><span class="line">    public Engine provideEngine()&#123;</span><br><span class="line">        return new Engine();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides</span><br><span class="line">    public Seat provideSeat()&#123;</span><br><span class="line">        return new Seat();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides</span><br><span class="line">    public Wheel provideWheel()&#123;</span><br><span class="line">        return new Wheel();</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 组件</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line">@Component(modules = CarModule.class)</span><br><span class="line">public interface CarComponent &#123;</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * 实现注入</span><br><span class="line">     * @param car</span><br><span class="line">     */</span><br><span class="line">    void inject(Car car);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 车</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Car &#123;</span><br><span class="line"></span><br><span class="line">    @Inject Engine mEngine;</span><br><span class="line">    @Inject Seat mSeat;</span><br><span class="line">    @Inject Wheel mWheel;</span><br><span class="line"></span><br><span class="line">    public Car() &#123;</span><br><span class="line">        DaggerCarComponent</span><br><span class="line">                .builder()</span><br><span class="line">                .carModule(new CarModule())</span><br><span class="line">                .build()</span><br><span class="line">                .inject(this);</span><br><span class="line">        Log.e(Config.TAG, &quot;Car: new Car()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">//  Component抽象类实现法</span><br><span class="line">/**</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/9</span><br><span class="line"> */</span><br><span class="line">@Component(modules = CarModule.class)</span><br><span class="line">public abstract class CarComponent &#123;</span><br><span class="line">    /**</span><br><span class="line">     * @param car</span><br><span class="line">     */</span><br><span class="line">    public abstract void inject(Car car);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>执行上一步的Android单元测试，打印结果<br><img src="http://upload-images.jianshu.io/upload_images/3110861-1c1b1e1c1bf426ae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图4.png"></p>
<p>####3. 以上用到的注解解释</p>
<ul>
<li>@Module 标注用来管理并提供依赖。里面定义一些用@Provides注解的以provide开头的方法，这些方法就是所提供的依赖，Dagger2会在该类中寻找实例化某个类所需要的依赖。</li>
<li>@Provides 标注用来提供依赖</li>
<li>@Component 标注接口或者抽象类，用来将@Inject和@Module联系起来的桥梁，从@Module中获取依赖并将依赖注入给@Inject。参数module，用来指定用注解@Module标识的类。</li>
<li>@Inject 标注目标类中所依赖的其他类，标注所依赖的其他类的构造函数</li>
</ul>
<p>####4. 多个构造方法<br>1). 给Engine类添加一个构造方法<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 引擎</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Engine &#123;</span><br><span class="line">    public Engine()&#123;</span><br><span class="line">        Log.e(Config.TAG, &quot;Engine: new Engine()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public Engine(String string)&#123;</span><br><span class="line">        Log.e(Config.TAG, &quot;Engine: &quot; + string);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>2). 此时运行之前的Android单元测试，发现它默认调用的是无参数的构造方法<br><img src="http://upload-images.jianshu.io/upload_images/3110861-f40865ff906700db.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图5.png"><br>3).  但此时我们就想让它去调用含一个参数的构造方法，我们可以这么做<br>I&gt;. 自定义一个注解，必须使用@Qualifier修饰器<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 标识引擎的颜色</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/9</span><br><span class="line"> */</span><br><span class="line">@Qualifier</span><br><span class="line">@Documented</span><br><span class="line">@Retention(RetentionPolicy.RUNTIME)</span><br><span class="line">public @interface EngineString &#123;</span><br><span class="line">    String string() default &quot;white&quot;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>II&gt;. 在CarModule中添加一个提供Engine的方法，并使用刚刚自定义的注解<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">@Module</span><br><span class="line">public class CarModule &#123;</span><br><span class="line">    @Provides</span><br><span class="line">    public Engine provideEngine()&#123;</span><br><span class="line">        return new Engine();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">// ... 省略其他的方法</span><br><span class="line"></span><br><span class="line">    @EngineString(string = &quot;black&quot;)</span><br><span class="line">    @Provides</span><br><span class="line">    public Engine provideStringEngine()&#123;</span><br><span class="line">        return new Engine(&quot;black&quot;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>III&gt;. 在Car类中，声明Engine的使用，同样也使用刚刚自定义的注解标识<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 车</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/8</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Car &#123;</span><br><span class="line">    @EngineString(string = &quot;black&quot;)</span><br><span class="line">    @Inject Engine mEngine;</span><br><span class="line">    @Inject Seat mSeat;</span><br><span class="line">    @Inject Wheel mWheel;</span><br><span class="line"></span><br><span class="line">    public Car() &#123;</span><br><span class="line">        DaggerCarComponent</span><br><span class="line">                .builder()</span><br><span class="line">                .carModule(new CarModule())</span><br><span class="line">                .build()</span><br><span class="line">                .inject(this);</span><br><span class="line">        Log.e(Config.TAG, &quot;Car: new Car()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>IV&gt;. 使用之前的Android单元测试<br><img src="http://upload-images.jianshu.io/upload_images/3110861-46f105b5e0abc095.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图6.png"></p>
<p>####5. @Named注解<br>@Named 是基于@Qualifier的注解，不过只能传递字符串<br>@Qualifier 包括但不限于字符串，如枚举等。</p>
<p>####6. Lazy<t>懒加载数据<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">public class Car &#123;</span><br><span class="line">    @EngineString(string = &quot;black&quot;)</span><br><span class="line">    @Inject Engine mEngineBlack;</span><br><span class="line">    @Named(value = &quot;10&quot;)</span><br><span class="line">    @Inject Engine mEngine;</span><br><span class="line">    @Inject Seat mSeat;</span><br><span class="line">    @Inject</span><br><span class="line">    Lazy&lt;Wheel&gt; mWheelLazy;</span><br><span class="line"></span><br><span class="line">    public Car() &#123;</span><br><span class="line">        DaggerCarComponent</span><br><span class="line">                .builder()</span><br><span class="line">                .carModule(new CarModule())</span><br><span class="line">                .build()</span><br><span class="line">                .inject(this);</span><br><span class="line">        Log.e(Config.TAG, &quot;Car: new Car()&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">    // 使用懒加载的变量</span><br><span class="line">    public void useWheel()&#123;</span><br><span class="line">        mWheelLazy.get();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></t></p>
<p>新建Android 单元测试<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">@Test</span><br><span class="line">public void testCar1()&#123;</span><br><span class="line">    final Car car = new Car();</span><br><span class="line">    new Thread(new Runnable() &#123;</span><br><span class="line">        @Override</span><br><span class="line">        public void run() &#123;</span><br><span class="line">            Log.e(&quot;tag&quot;, &quot;useWheel&quot; + Thread.currentThread());</span><br><span class="line">            car.useWheel();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;).start();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>单元测试打印结果:<br><img src="http://upload-images.jianshu.io/upload_images/3110861-915bd7624ec09cd0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图7.png"></p>
<p>####7. @Singleton 当前提供的对象将是单例模式 ,一般配合@Provides一起出现。</p>
<p>####8. 使用示例<br>AppModule.java<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/9</span><br><span class="line"> */</span><br><span class="line">@Module</span><br><span class="line">public class AppModule &#123;</span><br><span class="line">    Application mApplication;</span><br><span class="line">    public AppModule(Application application)&#123;</span><br><span class="line">        this.mApplication = application;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides</span><br><span class="line">    @Singleton</span><br><span class="line">    Application provideApplication()&#123;</span><br><span class="line">        return this.mApplication;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>NetModule.java<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * @author mazaiting</span><br><span class="line"> * @date 2018/1/9</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">@Module</span><br><span class="line">public class NetModule &#123;</span><br><span class="line">    String mBaseUrl;</span><br><span class="line"></span><br><span class="line">    // Constructor needs one parameter to instantiate.</span><br><span class="line">    public NetModule(String baseUrl) &#123;</span><br><span class="line">        this.mBaseUrl = baseUrl;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    // Dagger will only look for methods annotated with @Provides</span><br><span class="line">    @Provides</span><br><span class="line">    @Singleton</span><br><span class="line">    // Application reference must come from AppModule.class</span><br><span class="line">    SharedPreferences providesSharedPreferences(Application application) &#123;</span><br><span class="line">        return PreferenceManager.getDefaultSharedPreferences(application);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides</span><br><span class="line">    @Singleton</span><br><span class="line">    Cache provideOkHttpCache(Application application) &#123;</span><br><span class="line">        int cacheSize = 10 * 1024 * 1024; // 10 MiB</span><br><span class="line">        Cache cache = new Cache(application.getCacheDir(), cacheSize);</span><br><span class="line">        return cache;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides</span><br><span class="line">    @Singleton</span><br><span class="line">    Gson provideGson() &#123;</span><br><span class="line">        GsonBuilder gsonBuilder = new GsonBuilder();</span><br><span class="line">        gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);</span><br><span class="line">        return gsonBuilder.create();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides @Named(&quot;cached&quot;)</span><br><span class="line">    @Singleton</span><br><span class="line">    OkHttpClient provideOkHttpClientCache(Cache cache) &#123;</span><br><span class="line">        OkHttpClient.Builder builder = new OkHttpClient.Builder();</span><br><span class="line">        builder.cache(cache);</span><br><span class="line">        return builder.build();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides @Named(&quot;non_cached&quot;)</span><br><span class="line">    @Singleton</span><br><span class="line">    OkHttpClient provideOkHttpClient() &#123;</span><br><span class="line">        OkHttpClient.Builder builder = new OkHttpClient.Builder();</span><br><span class="line">        return builder.build();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Provides</span><br><span class="line">    @Singleton</span><br><span class="line">    Retrofit provideRetrofit(Gson gson, OkHttpClient okHttpClient) &#123;</span><br><span class="line">        Retrofit retrofit = new Retrofit.Builder()</span><br><span class="line">                .addConverterFactory(GsonConverterFactory.create(gson))</span><br><span class="line">                .baseUrl(mBaseUrl)</span><br><span class="line">                .client(okHttpClient)</span><br><span class="line">                .build();</span><br><span class="line">        return retrofit;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>NetComponent.java<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">@Singleton</span><br><span class="line">@Component(modules = &#123;AppModule.class, NetModule.class&#125;)</span><br><span class="line">public interface NetComponent &#123;</span><br><span class="line">    /**</span><br><span class="line">     * @param activity</span><br><span class="line">     */</span><br><span class="line">    void inject(MainActivity activity);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>完成前三个类之后编译，生成DaggerNetComponent.java.<br>MyApp.java<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">public class MyApp extends Application &#123;</span><br><span class="line">    private NetComponent mNetComponent;</span><br><span class="line">    @Override</span><br><span class="line">    public void onCreate() &#123;</span><br><span class="line">        super.onCreate();</span><br><span class="line"></span><br><span class="line">        mNetComponent =</span><br><span class="line">                DaggerNetComponent</span><br><span class="line">                .builder()</span><br><span class="line">                .appModule(new AppModule(this))</span><br><span class="line">                .netModule(new NetModule(&quot;http://www.baidu.com/&quot;))</span><br><span class="line">                .build();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public NetComponent getNetComponent()&#123;</span><br><span class="line">        return mNetComponent;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>MainActivity.java<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">public class MainActivity extends AppCompatActivity &#123;</span><br><span class="line">    @Inject @Named(&quot;cached&quot;)</span><br><span class="line">    OkHttpClient mClient;</span><br><span class="line">    @Inject @Named(&quot;non_cached&quot;)</span><br><span class="line">    OkHttpClient mOkHttpClient;</span><br><span class="line">    @Inject</span><br><span class="line">    SharedPreferences mSharedPreferences;</span><br><span class="line">    @Override</span><br><span class="line">    protected void onCreate(Bundle savedInstanceState) &#123;</span><br><span class="line">        super.onCreate(savedInstanceState);</span><br><span class="line">        setContentView(R.layout.activity_main);</span><br><span class="line"></span><br><span class="line">//        new Car();</span><br><span class="line">        ((MyApp)getApplication()).getNetComponent().inject(this);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    // 写数据</span><br><span class="line">    public void write(View view)&#123;</span><br><span class="line">        mSharedPreferences.edit().putString(&quot;key&quot;, &quot;value&quot;).apply();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    // 读数据</span><br><span class="line">    public void read(View view)&#123;</span><br><span class="line">        Toast.makeText(this, mSharedPreferences.getString(&quot;key&quot;, &quot;string&quot;), Toast.LENGTH_SHORT).show();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>activity_main.xml<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;LinearLayout</span><br><span class="line">    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    xmlns:tools=&quot;http://schemas.android.com/tools&quot;</span><br><span class="line">    android:id=&quot;@+id/activity_main&quot;</span><br><span class="line">    android:layout_width=&quot;match_parent&quot;</span><br><span class="line">    android:layout_height=&quot;match_parent&quot;</span><br><span class="line">    android:orientation=&quot;vertical&quot;</span><br><span class="line">    tools:context=&quot;com.mazaiting.dagger2test.MainActivity&quot;&gt;</span><br><span class="line"></span><br><span class="line">    &lt;Button</span><br><span class="line">        android:onClick=&quot;write&quot;</span><br><span class="line">        android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">        android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">        android:text=&quot;write&quot;/&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    &lt;Button</span><br><span class="line">        android:onClick=&quot;read&quot;</span><br><span class="line">        android:layout_width=&quot;wrap_content&quot;</span><br><span class="line">        android:layout_height=&quot;wrap_content&quot;</span><br><span class="line">        android:text=&quot;read&quot;/&gt;</span><br><span class="line">&lt;/LinearLayout&gt;</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/08/06/Android-Framework/Android-BaseRecyclerViewAdapterHelper使用/" rel="next" title="Android-BaseRecyclerViewAdapterHelper使用">
                <i class="fa fa-chevron-left"></i> Android-BaseRecyclerViewAdapterHelper使用
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/08/06/Android-Framework/Android-Design-Support-Library-v28/" rel="prev" title="Android-Design-Support-Library-v28">
                Android-Design-Support-Library-v28 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/blog/images/avatar.jpeg"
                alt="凌浩雨" />
            
              <p class="site-author-name" itemprop="name">凌浩雨</p>
              <p class="site-description motion-element" itemprop="description">专业从事于移动端开发，Android与iOS均有涉及，主做Android开发与React Native开发</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">393</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">凌浩雨</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
